package com.leetcode.problems026;


import com.leetcode.util.ListNode;

import java.util.Arrays;
import java.util.stream.Collectors;

/**
 * https://leetcode-cn.com/problems/merge-two-sorted-lists/
 * @Date 2021/11/20 14:34
 * @Author ghery
 * @Version V1.0
 */
public class Solution {

    public int removeDuplicates(int[] nums) {
        if(nums == null || nums.length <= 1){
            return 1;
        }
        int j = 0;
        for (int i = 1; i < nums.length; i++) {
            if( nums[i] != nums[j])
                nums[++j] = nums[i];
        }

        return j + 1;
    }


    public static void main(String[] args) {
        int[] arr = {1,2,2,2,3};
        System.out.println(new Solution().removeDuplicates(arr));
    }
}
